package cn.darksoul3.spark.operator

import org.apache.spark.{SparkConf, SparkContext}

object ReduceFoldSum {

  def main(args: Array[String]): Unit = {
    val conf = new SparkConf()
    conf.setAppName("group by key").setMaster("local[*]")

    val sc = new SparkContext(conf)

    val rdd1 = sc.parallelize(List(1, 2, 3, 4, 5, 6, 7), numSlices = 2)

    rdd1.reduce(_ + _)
    rdd1.fold(0)(_ + _)
    rdd1.sum()

  }
}
